//
//  MyTableViewController.swift
//  TableViewCollectionView
//
//  Created by lete on 2020/4/24.
//  Copyright © 2020 lete. All rights reserved.
//

import UIKit

class MyTableViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
    
   
    

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        setupTableViewUI()
        
    }
    
    
    func setupTableViewUI() {
        
        //创建 tableview
        let tableView = UITableView(frame: view.bounds, style: .plain)
        view.addSubview(tableView)
        
         //注册 cell
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cellId")
        //xib cell 的注册
//        tableView.register(UINib(nibName: "UITableViewCell", bundle: nil), forCellReuseIdentifier: "cellId")
       
        
        // 设置代理
        tableView.delegate = self
        tableView.dataSource = self
        
        
        
        
    }
    
    
    func numberOfSections(in tableView: UITableView) -> Int {
           return 3
       }
       func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
           return 20
       }
       
       func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
           
           let cell = tableView.dequeueReusableCell(withIdentifier: "cellId", for: indexPath)
           cell.textLabel?.text = "数据是\(indexPath.row)"
            return cell
       }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
